/*
 * main.cpp
 *
 *  Created on: Jan 27, 2013
 *      Author: Drew Prevost
 */

#include "Arduino.h"
#include "ThreadHybridSystemController.h"

#define KC_VM_PIN 6                                       //Keep charged voltageMonitor pin (main battery)
#define KC_VM_PIN_MIN 0                                   //Keep charged voltageMonitor pin reading min
#define KC_VM_PIN_MAX 1023                                //Keep charged voltageMonitor pin reading max
#define KC_VM_VOLTS_MIN 0                                 //Keep charged voltageMonitor volts input min
#define KC_VM_VOLTS_MAX 17.05                             //Keep charged voltageMonitor volts input max
#define KC_VM_READ_FREQ_MICROS 1000000                    //Keep charged voltageMonitor micros between reads
#define KC_ENG_SERVO_PIN 9                                //Keep charged exhaust clog servo pin
#define KC_ENG_SERVO_MAX_SPEED_IN_MICROS_PER_DEGREE 7843  //Keep charged exhaust clog servo max speed in micros per degree
#define KC_ENG_SERVO_INITIAL_POSITION 0                   //Keep charged exhaust servo initial position (open)
#define KC_ENG_PIN_GLOW_PLUG 0                            //Keep charged engine glow plug pin
#define KC_ENG_PIN_GEN_CONNECT 11                         //Keep charged engine generator connect pin
#define KC_ENG_PIN_STARTER_MOTOR 13                       //Keep charged engine generator starter motor pin
#define KC_ENG_PIN_GEN_DISCONNECT 12                      //Keep charged engine generator disconnect pin
#define KC_ENG_PIN_GENERATOR_MONITOR 8                    //Keep charged engine generator monitor pin
#define DC_TACH_PIN 2                                     //Drive controller load wheel tachometer pin (can only be pin two or three on the uno)
#define DC_TACH_IRQ_NUMBER 0                              //Drive controller load wheel tachometer interrupt number (pin two is zero, pin three is one)
#define DC_TACH_ISR_PIN 2                                 //Drive controller load wheel tachometer pin TODO: determine if this is needed.  It appears to be a repeat of DC_TACH_PIN
#define DC_TACH_ISR_MODE FALLING                          //Drive controller load wheel tachometer react type
#define DC_MOTOR_PIN 5                                    //Drive controller drive motor pin
#define DC_SERVO_PIN 3                                    //Drive controller clutch servo pin
#define DC_SERVO_MAX_SPEED_IN_MICROS_PER_DEGREE 7843      //Drive controller servo clutch max rate in micros per degree
#define DC_SERVO_INITIAL_POSITION 0                       //Drive controller servo clutch initial position (up)
#define DC_SERVO_INITIAL_RATE_IN_DEGREES_PER_SECOND 0     //TODO: find out if this is supposed to be micros per degree
ThreadHybridSystemController threadHybridSystemController( KC_VM_PIN, KC_VM_PIN_MIN, KC_VM_PIN_MAX, KC_VM_VOLTS_MIN, KC_VM_VOLTS_MAX, KC_VM_READ_FREQ_MICROS, KC_ENG_SERVO_PIN, KC_ENG_SERVO_MAX_SPEED_IN_MICROS_PER_DEGREE, KC_ENG_SERVO_INITIAL_POSITION, KC_ENG_PIN_GLOW_PLUG, KC_ENG_PIN_GEN_CONNECT, KC_ENG_PIN_STARTER_MOTOR, KC_ENG_PIN_GEN_DISCONNECT, KC_ENG_PIN_GENERATOR_MONITOR, DC_TACH_PIN, DC_TACH_IRQ_NUMBER, DC_TACH_ISR_PIN, DC_TACH_ISR_MODE, DC_MOTOR_PIN, DC_SERVO_PIN, DC_SERVO_MAX_SPEED_IN_MICROS_PER_DEGREE, DC_SERVO_INITIAL_POSITION, DC_SERVO_INITIAL_RATE_IN_DEGREES_PER_SECOND );

void setup()
{
}

void loop()
{
  threadHybridSystemController.run();
}
